package demo2;

import java.util.Arrays;

public abstract class Shape{
    public abstract double getArea();
    public abstract double getPerimeter();
}

class Triangle extends Shape{
    double a;
    double b;
    double c;

    public Triangle() {
    }

    public Triangle(double a, double b, double c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    public boolean isRightTriangle(double a, double b, double c) {
        double[] arr =new double[]{a,b,c};
        Arrays.sort(arr);
        return arr[0] + arr[1] > arr[2];
    }

    @Override
    public double getArea() {
        double p = (a + b + c) / 2;
        return Math.sqrt(p * (p - a) * (p - b) * (p - c));
    }

    @Override
    public double getPerimeter() {
        return this.a + this.b + this.c;
    }
}

class Circle extends Shape{
    double r;

    public Circle() {
    }

    public Circle(double r) {
        this.r = r;
    }

    @Override
    public double getArea() {
        return Math.PI * r * r;
    }

    @Override
    public double getPerimeter() {
        return 2 * Math.PI * r;
    }
}

class Rectangle extends Shape{
    double w;
    double l;
    public Rectangle() {
    }

    public Rectangle(double w, double l) {
        this.w = w;
        this.l = l;
    }

    @Override
    public double getArea() {
        return l * w;
    }

    @Override
    public double getPerimeter() {
        return 2 * (l + w);
    }
}
